FileUploadService.deleteImage   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
1
import { HttpClient } from "@angular/common/http";
2
import { Injectable } from "@angular/core";
3
import { Observable } from "rxjs";
4
import { environment } from "src/environments/environment";
5
6
@Injectable({
7
    providedIn: "root"
8
})
9
10
export class FileUploadService {
11
12
    private baseUrl = `${environment.api+"image"+"?API_KEY="+environment.api_key}`;
13
14
    constructor(private http: HttpClient) { }
15
16
    uploadImage(file: File): Observable<any> {
17
        let formData: any = new FormData();
18
        formData.append("image", file);
19
20
        return this.http.post(this.baseUrl, formData, {
21
            reportProgress: true,
22
            observe: "events",
23
        });
24
    }
25
26
    deleteImage(name: string): Observable<any> {
27
        const url = this.baseUrl+"&name="+name;
28
        return this.http.delete(url);
29
    }
30
}
31